/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control_ingresos_techpro;

import admin_conexion.AdminConexion;
import admin_conexion.ControlDatos;
import com.itextpdf.text.DocumentException;
import java.io.FileNotFoundException;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import pdfprinter.order_printer;

/**
 *
 * @author Chapas
 */
public class Ingreso_Ordenes extends javax.swing.JFrame {

    /**
     * Creates new form Ingreso_Ordenes
     */
    //tipos de trabajos y servicios prestados
    ArrayList<Servicio> Trabajos = new ArrayList<Servicio>();
    ArrayList<Servicio> TrabajosAdicionales = new ArrayList<Servicio>();
    ArrayList<Servicio> RepuestoAdicional = new ArrayList<Servicio>();
    boolean update = false;
    
    private AdminConexion aconect = new AdminConexion();
    private ControlDatos cdatos = new ControlDatos();
    order_printer impresora = new order_printer();

    public Ingreso_Ordenes() {
        initComponents();

        this.llenarClientes();
        // this.llenarAutos();

        Date fechaActual = new Date();
        SimpleDateFormat formato = new SimpleDateFormat("dd 'de' MMMM 'del' yyyy", getLocale());
        this.tfecha.setText(formato.format(fechaActual));


        Trabajos.add(new Servicio("Servicio Mediano (en el precio incluye aceite y filtro de aceite)",650.00, 1));
        Trabajos.add(new Servicio("Servicio al motor",0.00, 1));
        Trabajos.add(new Servicio("Cambio de aceite, filtro de aceite y filtro de aire",0.00, 1));
        Trabajos.add(new Servicio("Se cambió el refrigerante",0.00, 1));
        Trabajos.add(new Servicio("Se cambiaron bujías",0.00, 1));
        Trabajos.add(new Servicio("Servicio de frenos generales",0.00, 1));
        Trabajos.add(new Servicio("Se revisarion niveles en general",0.00, 1));
        Trabajos.add(new Servicio("Se revisarion luces y chorritos",0.00, 1));
        
        TrabajosAdicionales.add(new Servicio("Se cambiarion puntas de flecha",350.00, 2));
        
        RepuestoAdicional.add (new Servicio("Filtro de aire",60.00, 3));
        RepuestoAdicional.add (new Servicio("Bujías",120.00, 3));
        RepuestoAdicional.add (new Servicio("Refrigerante",60.00, 3));
        RepuestoAdicional.add (new Servicio("Puntas de flecha",650.00, 3));
        RepuestoAdicional.add (new Servicio("Alineación",150.00, 3));
        RepuestoAdicional.add (new Servicio("Batería",750.00, 3));
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        ccliente = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        lapellido = new javax.swing.JLabel();
        lfechaic = new javax.swing.JLabel();
        lnit = new javax.swing.JLabel();
        ltel2 = new javax.swing.JLabel();
        ltel1 = new javax.swing.JLabel();
        lnombre = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        cauto = new javax.swing.JComboBox();
        lmarca = new javax.swing.JLabel();
        llinea = new javax.swing.JLabel();
        laño = new javax.swing.JLabel();
        ltipo = new javax.swing.JLabel();
        lcolor = new javax.swing.JLabel();
        lfingreso = new javax.swing.JLabel();
        lrecorrido = new javax.swing.JLabel();
        lpservicio = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        trecorrido = new javax.swing.JFormattedTextField();
        tpservicio = new javax.swing.JFormattedTextField();
        ltipor = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabdetalle = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        tdescripcion = new javax.swing.JTextField();
        ctipos = new javax.swing.JComboBox();
        tcosto = new javax.swing.JFormattedTextField();
        jButton1 = new javax.swing.JButton();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        tfecha = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel3.setText("ID CLIENTE:");

        jLabel4.setText("NOMBRE:");

        jLabel5.setText("APELLIDO");

        jLabel6.setText("TEL1:");

        jLabel7.setText("TEL2:");

        ccliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cclienteActionPerformed(evt);
            }
        });

        jLabel8.setText("NIT:");

        jLabel9.setText("F. INGRESO:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lfechaic, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(47, 47, 47)
                        .addComponent(lnit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(41, 41, 41)
                        .addComponent(ltel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(41, 41, 41)
                        .addComponent(ltel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ccliente, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 159, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(lapellido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(lnombre, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(ccliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(lnombre))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(lapellido))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(ltel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(ltel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lnit))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(lfechaic))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel10.setText("PLACA:");

        jLabel11.setText("MARCA:");

        jLabel12.setText("LINEA");

        jLabel13.setText("AÑO:");

        jLabel14.setText("TIPO:");

        jLabel15.setText("COLOR:");

        jLabel16.setText("F. INGRESO");

        jLabel17.setText("RECORRIDO:");

        jLabel18.setText("SERVICIO:");

        cauto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cautoActionPerformed(evt);
            }
        });

        jLabel25.setText("PROX. SERVICIO:");

        jLabel26.setText("RECORRIDO ACT:");

        jButton3.setText("UPDATE");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        trecorrido.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        tpservicio.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16)
                    .addComponent(jLabel17)
                    .addComponent(jLabel18))
                .addGap(21, 21, 21)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cauto, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lrecorrido, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lpservicio, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel25)
                                    .addComponent(jLabel26))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(trecorrido, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
                                    .addComponent(tpservicio))
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(16, 16, 16)
                                        .addComponent(jButton3))
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(ltipor)))))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lmarca, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(llinea, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lfingreso, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lcolor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(ltipo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(laño, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(cauto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lmarca, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(llinea, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(laño, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(ltipo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lcolor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lfingreso, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lrecorrido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel26)
                        .addComponent(trecorrido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(ltipor, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel25)
                            .addComponent(jButton3)
                            .addComponent(tpservicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(lpservicio, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel18, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jLabel1.setText("Información del cliente");

        jLabel2.setText("Información del vehículo");

        tabdetalle.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Descripción", "Costo", "Tipo de Servicio"
            }
        ));
        jScrollPane1.setViewportView(tabdetalle);

        jLabel19.setText("Ingreso de Servicios");

        tdescripcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tdescripcionActionPerformed(evt);
            }
        });

        ctipos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TRABAJO", "TRABAJO ADICIONAL", "REPUESTO ADICIONAL" }));
        ctipos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ctiposActionPerformed(evt);
            }
        });

        tcosto.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###.00"))));
        tcosto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tcostoActionPerformed(evt);
            }
        });

        jButton1.setText("AGREGAR");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel21.setText("Descripción del servicio:");

        jLabel22.setText("Costo:");

        jLabel23.setText("Tipo:");

        jLabel20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/media/Grupo TecProTeam SMALL.png"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel19)
                        .addGap(130, 130, 130)
                        .addComponent(jLabel22)
                        .addGap(89, 89, 89)
                        .addComponent(jLabel23)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(tdescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 571, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tcosto, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ctipos, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel20)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel19)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(jLabel22)
                    .addComponent(jLabel23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tdescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tcosto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ctipos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel20)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel24.setText("Fecha:");

        tfecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfechaActionPerformed(evt);
            }
        });

        jMenu1.setText("File");
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });

        jMenuItem1.setText("Imprimir Orden");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jScrollPane1))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(55, 55, 55)
                                .addComponent(jLabel1))
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel2)
                                .addGap(110, 110, 110)
                                .addComponent(jLabel24)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(tfecha))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel24)
                    .addComponent(tfecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tdescripcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tdescripcionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tdescripcionActionPerformed

    private void ctiposActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ctiposActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ctiposActionPerformed
    private void tcostoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tcostoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tcostoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        agregarServicio();        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void cclienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cclienteActionPerformed
        updateCliente();// TODO add your handling code here:
    }//GEN-LAST:event_cclienteActionPerformed

    private void cautoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cautoActionPerformed
        this.update = false;
        updateVehiculo();        // TODO add your handling code here:
    }//GEN-LAST:event_cautoActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
         printOrden();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void tfechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfechaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfechaActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        updateDatosV();        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
         // TODO add your handling code here:
    }//GEN-LAST:event_jMenu1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Ingreso_Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Ingreso_Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Ingreso_Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Ingreso_Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ingreso_Ordenes().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cauto;
    private javax.swing.JComboBox ccliente;
    private javax.swing.JComboBox ctipos;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lapellido;
    private javax.swing.JLabel laño;
    private javax.swing.JLabel lcolor;
    private javax.swing.JLabel lfechaic;
    private javax.swing.JLabel lfingreso;
    private javax.swing.JLabel llinea;
    private javax.swing.JLabel lmarca;
    private javax.swing.JLabel lnit;
    private javax.swing.JLabel lnombre;
    private javax.swing.JLabel lpservicio;
    private javax.swing.JLabel lrecorrido;
    private javax.swing.JLabel ltel1;
    private javax.swing.JLabel ltel2;
    private javax.swing.JLabel ltipo;
    private javax.swing.JLabel ltipor;
    private javax.swing.JTable tabdetalle;
    private javax.swing.JFormattedTextField tcosto;
    private javax.swing.JTextField tdescripcion;
    private javax.swing.JTextField tfecha;
    private javax.swing.JFormattedTextField tpservicio;
    private javax.swing.JFormattedTextField trecorrido;
    // End of variables declaration//GEN-END:variables

    private void updateTabla() {
        DefaultTableModel modelo = new DefaultTableModel();
        modelo = (DefaultTableModel) this.tabdetalle.getModel();

        while (modelo.getRowCount() > 0) {
            modelo.removeRow(0);
        }

        for (Servicio aux : this.Trabajos) {
            Object[] fila = new Object[3];
            fila[0] = aux.getDescripcion();
            fila[1] = aux.getCosto();
            switch (aux.getTipoServicio()) {
                case 1:
                    fila[2] = "Trabajo";
                    break;
//                case 2:
//                    fila[2] = "Trabajo Adicional";
//                    ;
//                    break;
//                case 3:
//                    fila[2] = "Respuesto Adicional";
//                    ;
//                    break;
            }

            modelo.addRow(fila);
        }

        for (Servicio aux : this.TrabajosAdicionales) {
            Object[] fila = new Object[3];
            fila[0] = aux.getDescripcion();
            fila[1] = aux.getCosto();
            switch (aux.getTipoServicio()) {
//                case 1:
//                    fila[2] = "Trabajo";
//                    break;
                case 2:
                    fila[2] = "Trabajo Adicional";
                    ;
                    break;
//                case 3:
//                    fila[2] = "Respuesto Adicional";
//                    ;
//                    break;
            }
            modelo.addRow(fila);

        }

        for (Servicio aux : this.RepuestoAdicional) {
            Object[] fila = new Object[3];
            fila[0] = aux.getDescripcion();
            fila[1] = aux.getCosto();
            switch (aux.getTipoServicio()) {
//                case 1:
//                    fila[2] = "Trabajo";
//                    break;
//                case 2:
//                    fila[2] = "Trabajo Adicional";
//                    ;
//                    break;
                case 3:
                    fila[2] = "Respuesto Adicional";
                    ;
                    break;
            }
            modelo.addRow(fila);

        }



    }

    private void insertServicio(Servicio n) {

        int tiposervicio = n.getTipoServicio();

        switch (tiposervicio) {
            case 1:
                this.Trabajos.add(n);
                break;
            case 2:
                this.TrabajosAdicionales.add(n);
                break;
            case 3:
                this.RepuestoAdicional.add(n);
                break;


        }


    }

    private void agregarServicio() {
        if (verificar()) {

            String serv = this.tdescripcion.getText().trim();
            float cost = Float.parseFloat(this.tcosto.getText().trim());
            int tipo = this.ctipos.getSelectedIndex();
            insertServicio(new Servicio(serv, cost, tipo + 1));

            System.out.println("Nuevo Servicio agregado: " + serv + " " + cost + " " + (tipo + 1) + "");

        }

        this.updateTabla();
    }

    private boolean verificar() {
        boolean aprobado = true;

        if (this.tdescripcion.getText().trim().equalsIgnoreCase("")) {
            aprobado = false;
            JOptionPane.showMessageDialog(this, "La DESCRIPCION del servicio está en blanco!", "Error de entrada", JOptionPane.ERROR_MESSAGE);
        }

        if (this.tdescripcion.getText().trim().equalsIgnoreCase("")) {
            aprobado = false;
            JOptionPane.showMessageDialog(this, "El COSTO del servicio es incorrecto o está en blanco!", "Error de entrada", JOptionPane.ERROR_MESSAGE);
        }
        
        return aprobado;
    }

    private void llenarClientes() {


        this.ccliente.removeAllItems();
        try {


            aconect.abrirConexionBDD();
            ResultSet clientes = aconect.consulta("SELECT * FROM tecpro.cliente");
            while (clientes.next()) {
                String objeto = clientes.getObject("idcliente").toString() + "-" + clientes.getObject("nombre").toString() + "-" + clientes.getObject("apellido").toString();
                this.ccliente.addItem(objeto);
            }
            aconect.cerrarConexionBDD();
        } catch (Exception e) {
            System.out.println("Fallo llenar clientes: " + e);
        }

    }

    private void llenarAutos() {

        this.cauto.removeAllItems();
        String cliente = this.ccliente.getSelectedItem().toString();
        String[] campos = cliente.split("-");


        try {

            aconect.abrirConexionBDD();
            ResultSet vehiculo = aconect.consulta("SELECT * FROM tecpro.vehiculo where cliente_idcliente=" + campos[0] + ";");
            while (vehiculo.next()) {
                String objeto = vehiculo.getObject("placa").toString() + "-" + vehiculo.getObject("linea").toString() + "-" + vehiculo.getObject("color").toString();
                this.cauto.addItem(objeto);
            }
            aconect.cerrarConexionBDD();
        } catch (Exception e) {
            System.out.println("Fallo llenar Vehiculos: " + e);
        }

    }

    private void updateCliente() {
        String cliente = this.ccliente.getSelectedItem().toString();
        String[] campos = cliente.split("-");

        System.out.println("El id seleccionado es: " + campos[0]);

        try {
            aconect.abrirConexionBDD();
            ResultSet cli = aconect.consulta("SELECT * FROM tecpro.cliente WHERE idcliente = '" + campos[0] + "'");
            while (cli.next()) {

                this.lnombre.setText(cli.getObject("nombre").toString());
                this.lapellido.setText(cli.getObject("apellido").toString());

                try {
                    this.ltel1.setText(cli.getObject("tel_casa").toString());
                } catch (Exception e) {
                    System.out.println("" + e);
                    this.ltel1.setText("");
                }

                try {
                    this.ltel2.setText(cli.getObject("tel_movil").toString());
                } catch (Exception e) {
                    System.out.println("" + e);
                    this.ltel2.setText("");
                }

                try {
                    this.lnit.setText(cli.getObject("nit").toString());
                } catch (Exception e) {
                    this.lnit.setText("");
                }

                String date1 = cli.getObject("fecha_ingreso").toString();
                String[] date = date1.split("-");
                String newdate = date[2] + "/" + date[1] + "/" + date[0];
                this.lfechaic.setText(newdate);
            }
            aconect.cerrarConexionBDD();

            llenarAutos();
        } catch (Exception e) {
            System.out.println("Fallo Obtener datos del cliente!!" + e);
        }



    }

    private void updateVehiculo() {
        
        
        
        String auto = this.cauto.getSelectedItem().toString();
        String[] campos = auto.split("-");

        try {
            aconect.abrirConexionBDD();
            System.out.println("SELECT * FROM tecpro.vehiculo WHERE placa = '" + campos[0] + "-" + campos[1] + "'");
            ResultSet vehi = aconect.consulta("SELECT * FROM tecpro.vehiculo WHERE placa = '" + campos[0] + "-" + campos[1] + "'");
            while (vehi.next()) {

                this.lmarca.setText(vehi.getObject("marca").toString());
                this.llinea.setText(vehi.getObject("linea").toString());
                this.laño.setText(vehi.getObject("anio").toString());
                this.ltipo.setText(vehi.getObject("tipo").toString());
                this.lcolor.setText(vehi.getObject("color").toString());
                this.lrecorrido.setText(vehi.getObject("recorrido").toString() + " " + vehi.getObject("tipo_recorrido").toString());
                this.trecorrido.setText(vehi.getObject("recorrido").toString());
                this.ltipor.setText(vehi.getObject("tipo_recorrido").toString());
                

                try {
                    this.lpservicio.setText(vehi.getObject("prox_servicio").toString());
                    this.tpservicio.setText(vehi.getObject("prox_servicio").toString());
                } catch (Exception e) {
                    this.lnit.setText("");
                }

                String date1 = vehi.getObject("fecha_ingreso").toString();
                String[] date = date1.split("-");
                String newdate = date[2] + "/" + date[1] + "/" + date[0];
                this.lfingreso.setText(newdate);
            }
            aconect.cerrarConexionBDD();

            //llenarAutos();
        } catch (Exception e) {
            System.out.println("Fallo Obtener datos del vehículo!!" + e);
        }


    }

    public void printOrden() {

        if (this.update){
        String cliente = "";
        String vehiculo ="";
        String detalle ="";

        cliente = this.lnombre.getText() + " " + this.lapellido.getText();

        String auto = this.cauto.getSelectedItem().toString();
        String[] campos = auto.split("-");
        vehiculo += campos[0] + "-" + campos[1]+"/";
        vehiculo += this.lmarca.getText()+ "/";
        vehiculo += this.llinea.getText()+ "/";
        vehiculo += this.laño.getText() + "/";
        vehiculo += this.lcolor.getText()+ "/";
        vehiculo += this.lrecorrido.getText()+ "/";
        

       

        try {
            impresora.imprimir_orden(this.tfecha.getText().trim(), this.lrecorrido.getText().trim(), this.tpservicio.getText().trim(),cliente, vehiculo, this.Trabajos,this.TrabajosAdicionales, this.RepuestoAdicional);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Ingreso_Ordenes.class.getName()).log(Level.SEVERE, null, ex);
        } catch (DocumentException ex) {
            Logger.getLogger(Ingreso_Ordenes.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        }else {
            
            JOptionPane.showMessageDialog(this, "No se ha actualizado el RECORRIDO/PROX SERVICIO", "Error de actualización", JOptionPane.ERROR_MESSAGE);
        }

    }

    private boolean updateDatosV() {
        
        boolean up = true;
        int recorrido = 0;
        int servicio = 0;
        
        //obtener datos
        if (verificarDatosV()){
        
            recorrido = Integer.parseInt(this.trecorrido.getText());
            servicio = Integer.parseInt(this.tpservicio.getText());
       
        
                     
        //hacer el update
        String auto = this.cauto.getSelectedItem().toString();
        String[] campos = auto.split("-");
        
        try {
            this.cdatos.updateRecorridoyServicio(campos[0] + "-" + campos[1], recorrido, servicio);
            this.update= true;
            JOptionPane.showMessageDialog(this, "Update Realizado con éxito!", "Update Exitoso", JOptionPane.INFORMATION_MESSAGE);
            
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "El update no se realizó,! \n"+ e, "Error de entrada", JOptionPane.ERROR_MESSAGE);
            
        }
        updateVehiculo();
        }
        return up;
        
    }
    
    private boolean verificarDatosV (){

    boolean pass = true;
    
    try {
            Integer.parseInt(this.trecorrido.getText());
            Integer.parseInt(this.tpservicio.getText());
        } catch (Exception e) {            
            JOptionPane.showMessageDialog(this, "Los datos de RECORRIDO/SERVICIO son incorrectos!", "Error de entrada", JOptionPane.ERROR_MESSAGE);
            pass = false;            
        }
    return pass;
    }
   
}